/**
 * This class give more specific implementation and construct
 * for missing records
 */
package com.comp6231.replica2.server;

import com.comp6231.replica2.server.helper.IndividualsStatus;

/**
 * @author Farzana Alam
 * 
 */
public class CriminalRecord extends Record {

	private String crimeDescription;

	/**
	 * @param badgeID
	 * @param recordID
	 * @param lastName
	 * @param firstName
	 * @param description
	 * @param status
	 */
	public CriminalRecord(String badgeID, String recordID, String lastName,
			String firstName, String description, IndividualsStatus status) {
		super(badgeID, lastName, firstName, status, recordID);

		this.crimeDescription = description;
	}

	/**
	 * @return
	 */
	public String getDescription() {
		return crimeDescription;
	}

	/**
	 * 
	 * @param description
	 */
	public void setDescription(String description) {
		this.crimeDescription = description;
	}

	public static Record makeCRObject(String myRecord) {
		/*
		 * the following string format is expected as myRecord
		 * recoredID:lastName:firstName:description:status:badgeID
		 */

		String[] temp = myRecord.split(":");

		IndividualsStatus status = null;

		switch (temp[4].toUpperCase()) {
		case "MISSING":
			status = IndividualsStatus.from_int(0);
			break;
		case "FOUND":
			status = IndividualsStatus.from_int(0);
			break;
		case "ON_THE_RUN":
			status = IndividualsStatus.from_int(0);
			break;
		case "CAPTURED":
			status = IndividualsStatus.from_int(0);
			break;

		}
		return new CriminalRecord(temp[5], temp[0], temp[1], temp[2], temp[3],
				status);
	}

	@Override
	public String toString() {
		// recoredID:lastName:firstName:description:status:badgeID
		StringBuilder sb = new StringBuilder();
		sb.append(getRecordID()).append("##").append(getLastName())
				.append("##").append(getFirstName()).append("##")
				.append(getDescription());
		sb.append("##").append(getStatus().toString()).append("##")
				.append(getBadgeID());

		return sb.toString();
	}

}
